<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>入职申请</title>
    <script src="../../../../res/js/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="../../../../res/js/login_common.js" charset="utf-8"></script>
    <script src="../../../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../../../res/js/Tools.js" charset="utf-8"></script>
    <link rel="shortcut icon" type="image/x-icon" href="../../../../res/images/favicon.ico">
    <link rel="stylesheet" href="../../../../res/layui/css/layui.css" media="all">
    <style>
        #isHealthMaimLevel{
            display: none;
        }
    </style>
</head>
<body style="padding: 10px">
<div style="display: none" id="bodys">
<form action="" class="layui-form layui-form-pane" lay-filter="example">
    <h1 align="center" style="margin-bottom: 20px">员工入职登记表</h1>
    <input name="pkEntryId" id="pkEntryId" type="hidden"/>
    <input name="isRevision" id="isRevision" type="hidden"/>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="required" name="entryArea"
                       id="entryArea" placeholder="请输入名字（必填）"
                       type="text"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">出生日期</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryBirthday" lay-verify="date" name="entryBirthday"
                       placeholder="yyyy-MM-dd"
                       type="text">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">身份证号</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="required" id="entryIdentity"
                       name="entryIdentity" placeholder="请输入身份证号（必填）"
                       type="text"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">民族</label>
            <div class="layui-input-inline">
                <select lay-verify="required" lay-search="" id="entryNation" name="entryNation" lay-search="">
                    <option value="">请选择民族（必填）</option>
                    <option value="1">研发</option>
                    <option value="2">打酱油</option>
                    <option value="3">测试</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">籍贯</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="required" name="entryNativeProvince"
                       id="entryNativeProvince" placeholder="请输入籍贯（必填）"
                       type="text"/>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryPhone" lay-verify="required|phone" name="entryPhone"
                       placeholder="电话（必填）"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">最高学历</label>
            <div class="layui-input-inline">
                <select lay-verify="required" id="entryEducation" name="entryEducation">
                    <option value="">请选择学历（必填）</option>
                    <option value="1">研发</option>
                    <option value="2">打酱油</option>
                    <option value="3">测试</option>
                </select>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">专业</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryMajor" lay-verify="required" name="entryMajor"
                       placeholder="专业（必填）"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">外语及等级</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryForeignLevel" lay-verify="required"
                       name="entryForeignLevel"
                       placeholder="外语及等级（必填）"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">职业资格</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryProfessionalQualification" lay-verify="required"
                       name="entryProfessionalQualification"
                       placeholder="职业资格（必填）"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">专业职称</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryMajorQualification" lay-verify="required"
                       name="entryMajorQualification"
                       placeholder="专业职称（必填）"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">银行账户</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryBankAccount" lay-verify="required"
                       name="entryBankAccount"
                       placeholder="银行账户（必填）"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">开户行</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="entryBankName" lay-verify="required"
                       name="entryBankName"
                       placeholder="开户行（必填）"
                       type="text">
            </div>
        </div>

        <div class="layui-form-item" style="width: 296px;display: inline-block;" pane="">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" id="entrySexMan" name="entrySex" value="1" title="男" checked="">
                <input type="radio" id="entrySexGirl" name="entrySex" value="0" title="女">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">户口所在地</label>
        <div class="layui-input-block">
            <input type="text" name="entryNativeCity" id="entryNativeCity" lay-verify="required" autocomplete="off"
                   placeholder="户口所在地（必填）"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" pane="">
        <label class="layui-form-label">婚姻状况</label>
        <div class="layui-input-block">
            <input type="radio" id="isMarriage0" name="isMarriage" value="0" title="已婚">
            <input type="radio" id="isMarriage1" name="isMarriage" value="1" title="未婚" checked="">
            <input type="radio" id="isMarriage3" name="isMarriage" value="3" title="再婚">
            <input type="radio" id="isMarriage2" name="isMarriage" value="2" title="离异">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">现住邮编</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" lay-verify="required" name="entryPostcode"
                   id="entryPostcode" placeholder="请输入邮编（必填）"
                   type="text"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">现住地址</label>
        <div class="layui-input-block">
            <input type="text" name="entryCurrentResidence" id="entryCurrentResidence" lay-verify="required"
                   autocomplete="off" placeholder="现住地址（必填）"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">通信邮编</label>
        <div class="layui-input-inline">
            <input autocomplete="off" class="layui-input" lay-verify="required" name="entryPostcodeResidence"
                   id="entryPostcodeResidence" placeholder="请输入邮编（必填）"
                   type="text"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">通信地址</label>
        <div class="layui-input-block">
            <input type="text" name="entryCommunicationResidence" id="entryCommunicationResidence" lay-verify="required"
                   autocomplete="off" placeholder="通信地址（必填）"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">身高</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="healthHeight"
                       name="healthHeight"
                       placeholder="身高"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">体重</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" id="healthWeight"
                       name="healthWeight"
                       placeholder="体重"
                       type="text">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">参加工作时间</label>
            <div class="layui-input-inline">
                <input type="text" name="dimissionTime" id="dimissionTime" lay-verify="date" placeholder="yyyy-MM-dd（必填）"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">累计工作时间</label>
            <div class="layui-input-inline">
                <input autocomplete="off" class="layui-input" lay-verify="required" id="accumulativeDate"
                       name="accumulativeDate" placeholder="累计工作时间（必填）"
                       type="text"/>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">应聘信息来源</label>
            <div class="layui-input-inline">
                <select lay-verify="required" name="recruitmentInformation" id="recruitmentInformation">
                    <option value="">请选择等级（必填）</option>
                    <option value="1">研发</option>
                    <option value="2">打酱油</option>
                    <option value="3">测试</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">入职部门</label>
            <div class="layui-input-inline">
                <select lay-verify="required" lay-filter="departmentId" name="departmentId" id="departmentId" lay-search="">
                    <option value="">请选择部门（必填）</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">入职岗位</label>
            <div class="layui-input-inline">
                <select lay-verify="required" name="postId" id="postId" lay-search="">
                    <option value="">请选择岗位（必填）</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label" style="width: 116px">入职时间</label>
            <div class="layui-input-inline">
                <input type="text" name="affirmTime" id="affirmTime" lay-verify="date" placeholder="yyyy-MM-dd（必填）"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" style="width: 303px;display: inline-block;margin-right:20px;" pane="">
            <label class="layui-form-label" style="width: 116px">视力</label>
            <div class="layui-input-block">
                <input type="radio" id="isHealthEyesight1" name="isHealthEyesight" value="1" title="良好" checked="">
                <input type="radio" id="isHealthEyesight0" name="isHealthEyesight" value="0" title="辅助">
            </div>
        </div>
        <div class="layui-form-item" style="width: 303px;display: inline-block;" pane="">
            <label class="layui-form-label" style="width: 116px">听力</label>
            <div class="layui-input-block">
                <input type="radio" id="isHealthEar1" name="isHealthEar" value="1" title="良好" checked="">
                <input type="radio" id="isHealthEar0" name="isHealthEar" value="0" title="辅助">
            </div>
        </div>
    </div>


    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">录用条件</label>
        <div class="layui-input-block">
            <textarea type="textarea" id="employCondition" name="employCondition" class="layui-textarea">
            </textarea>
        </div>
    </div>
    <div>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block" id="oaEntryEducations">
                <fieldset class="layui-elem-field">
                    <legend><button type="button" id="education" class="layui-btn">新增教育经历</button></legend>
                    <div class="layui-field-box">
                        <table class="layui-table" id="oaEntryEducation"
                               lay-filter="oaEntryEducation">
                        </table>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block" id="oaEntryWorks">
                <fieldset class="layui-elem-field">
                    <legend><button type="button" id="entrywork" class="layui-btn">新增工作经历</button></legend>
                    <div class="layui-field-box">
                        <table class="layui-table" id="oaEntryWork"
                               lay-filter="oaEntryWork">

                        </table>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block" id="oaEntryTrains">
                <fieldset class="layui-elem-field">
                    <legend><button type="button" id="entryTrain" class="layui-btn">新增培训经历</button></legend>
                    <div class="layui-field-box">
                        <table class="layui-table" id="oaEntryTrain"
                               lay-filter="oaEntryTrain">
                        </table>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block" id="oaEntryFamilys">
                <fieldset class="layui-elem-field">
                    <legend><button type="button" id="entryFamily" class="layui-btn">新增家庭成员</button></legend>
                    <div class="layui-field-box">
                        <table class="layui-table" id="oaEntryFamily"
                               lay-filter="oaEntryFamily">
                        </table>
                    </div>
                </fieldset>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <div class="layui-input-block" id="oaEmergencyContacts">
                <fieldset class="layui-elem-field">
                    <legend><button type="button" id="emergencyContact" class="layui-btn">新增紧急联络人</button></legend>
                    <div class="layui-field-box">
                        <table class="layui-table" id="oaEmergencyContact"
                               lay-filter="oaEmergencyContact">

                        </table>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-form-item" pane="" style="width: 525px;float: left">
            <label class="layui-form-label" style="width: 455px">是否曾被认定为工伤或职业病或持有残疾人证明</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="isHealthInjury" id="isHealthInjury" lay-skin="switch" lay-text="是|否">
            </div>
        </div>


        <div class="layui-form-item" pane="" style="width: 525px;float: left">
            <label class="layui-form-label" style="width: 455px">是否从事过井下、高空、高温、特别繁重体力劳动已经有毒有害工种</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="isHealthHeavyManual" id="isHealthHeavyManual" lay-skin="switch" lay-text="是|否">
            </div>
        </div>
        <div class="layui-form-item" pane="" style="width: 525px;float: left">
            <label class="layui-form-label" style="width: 455px">是否有传染性疾病以及何疾病</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="isHealthContagion" id="isHealthContagion" lay-skin="switch" lay-text="是|否">
            </div>
        </div>
        <div class="layui-form-item" pane="" style="width: 525px;float: left">
            <label class="layui-form-label" style="width: 455px">是否已经休了本年度年休假</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="isAnnualVacation" id="isAnnualVacation" lay-skin="switch" lay-text="是|否">
            </div>
        </div>

        <div class="layui-form-item" pane="" style="width: 525px;float: left">
            <label class="layui-form-label" style="width: 455px">是否曾经或正在追究与承担过刑事责任</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="isPenal" id="isPenal"  lay-skin="switch" lay-text="是|否">
            </div>
        </div>

        <div class="layui-form-item" pane="" style="width: 525px;float: left">
            <label class="layui-form-label" style="width: 455px">是否在本公司工作过</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="formeWork" id="formeWork" lay-skin="switch" lay-text="是|否">
            </div>
        </div>
        <div class="layui-form-item" pane="" style="width: 525px;float: left" id="isHealthMaims">
            <label class="layui-form-label" style="width: 455px">是否被劳动能力鉴定委员会鉴定为具有伤残等级以及几何级伤残</label>
            <div class="layui-input-block" style="margin-left: 455px;">
                <input type="checkbox" name="isHealthMaim" id="isHealthMaim" lay-filter="switchTest" lay-skin="switch" lay-text="是|否">
                <div id="isHealthMaimLevel">
                    <select name="healthMaimGrade" id="healthMaimGrade">
                        <option value="">请选择等级</option>
                        <option value="1">研发</option>
                        <option value="2">打酱油</option>
                        <option value="3">测试</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 455px">最近六个月内所接收的医学治疗于医学检查</label>
        <div class="layui-input-block" style="margin-left:455px">
            <input type="text" name="healthTreat" id="healthTreat" autocomplete="off" placeholder="请输入"
                   class="layui-input">
        </div>
    </div>

    <!-- 提交-->
    <div class="layui-form-item" id="sub">
        <div class="layui-input-block" id="flows">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <input type="button" class="layui-btn layui-btn-normal" id="demo2" value="暂存" />
        </div>

    </div>
</form>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>流程日志</legend>
</fieldset>
<ul class="layui-timeline" id="schedule">

</ul>
</div>
<script type="text/html" id="barDemoOaEntryEducation">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delOaEntryEducation">删除</a>
</script>
<script type="text/html" id="barDemoOaEntryWork">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delEntryWork">删除</a>
</script>
<script type="text/html" id="barDemoOaEntryTrain">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delEntryTrain">删除</a>
</script>
<script type="text/html" id="barDemoOaEntryFamily">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delEntryFamily">删除</a>
</script>
<script type="text/html" id="barDemoEmergencyContact">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delEmergencyContact">删除</a>
</script>
<script>
    let oaEntryEducationTable; // 教育经历
    let oaEntryWorkTable; //工作经历
    let oaEntryTrainTable; //培训经历
    let oaEntryFamilyTable; // 家庭成员
    let oaEmergencyContactTable; // 紧急联络人
    let pkEntryId = getQueryString("pkEntryId");
    layui.use(['form', 'laydate', 'table'], function () {
        var table = layui.table;
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;
        //身份证验证
        $("#entryIdentity").on('blur',function () {
            console.info($("#entryIdentity").val());
            var reg=/(^\d{15}$)|(^\d{17}(x|X|\d)$)/;
            if(!reg.test($("#entryIdentity").val())){
                layer.alert("请输入正确的身份证号", {
                    icon: 2,
                },function () {
                    layer.msg('请重新输入', {icon: 0});
                    $("#entryIdentity").val("");
                    $("#entryIdentity").focus();
                });

            }
        });



        //点击教育经历的监听方法
        $("#education").on("click",function () {
            layer.open({
                type: 2,
                title: '增加操作',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['90%', '90%'],
                content: 'education/education.html?id='+$("#pkEntryId").val()
            });
        });
        //点击工作经历的监听方法
        $("#entrywork").on("click",function () {
            layer.open({
                type: 2,
                title: '增加操作',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['90%', '90%'],
                content: 'entrywork/entrywork.html?id='+$("#pkEntryId").val()
            });
        });
        //点击培训经历的监听方法
        $("#entryTrain").on("click",function () {
            layer.open({
                type: 2,
                title: '增加操作',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['90%', '90%'],
                content: 'entryTrain/entryTrain.html?id='+$("#pkEntryId").val()
            });
        });
        //监听家庭成员
        $("#entryFamily").on("click",function () {
            layer.open({
                type: 2,
                title: '增加操作',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['90%', '90%'],
                content: 'entryfamily/entryfamily.html?id='+$("#pkEntryId").val()
            });
        });
        //监听新增紧急联系人
        $("#emergencyContact").on("click",function () {
            layer.open({
                type: 2,
                title: '增加操作',
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['90%', '90%'],
                content: 'emergencyContact/emergencyContact.html?id='+$("#pkEntryId").val()
            });
        });

        //出生日期
        laydate.render({
            elem: '#entryBirthday'
        });
        //参加工作时间
        laydate.render({
            elem: '#dimissionTime'
        });
        //入职日期
        laydate.render({
            elem: '#affirmTime'
        });

        //加载民族下拉框
        const nation=getAjaxById(getRootPath()+"OaDataDictionaryAction/findKeyword/NATION");
        $("#entryNation").html('<option value="">请选择民族（必填）</option>');
        $.each(nation,function (index,item) {
            $("#entryNation").append('<option value="'+item.pkDataDictionaryId+'">'+item.dataDictionaryName+'</option>')
        });

        //加载学历下拉框
        const education=getAjaxById(getRootPath()+"OaDataDictionaryAction/findKeyword/EDUCATION");
        $("#entryEducation").html('<option value="">请选择学历（必填）</option>');
        $.each(education,function (index,item) {
            $("#entryEducation").append('<option value="'+item.pkDataDictionaryId+'">'+item.dataDictionaryName+'</option>')
        });

        //加载部门下拉框
        const departmentId=getAjaxById(getRootPath()+"OaDepartmentAction/departmentfindByAll");
        $("#departmentId").html('<option value="">请选择部门（必填）</option>');
        $.each(departmentId.data,function (index,item) {
            $("#departmentId").append('<option value="'+item.pkDepartmentId+'">'+item.departmentName+'</option>')
        });

        form.on('select(departmentId)', function(data){
            if(data.value){
                //加载岗位下拉框
                const postId=getAjaxById(getRootPath()+"OaOrganizationAction/organizationFind/"+data.value);
                $("#postId").html('<option value="">请选择岗位（必填）</option>');
                $.each(postId.data,function (index,item) {
                    $("#postId").append('<option value="'+item.pkPostId+'">'+item.postName+'</option>')
                });
            }else{
                $("#postId").html('<option value="">请选择岗位（必填）</option>');
            }
            form.render();
        });

        //加载应聘信息来源下拉框
        const recruitmentInformation=getAjaxById(getRootPath()+"OaDataDictionaryAction/findKeyword/ORIGIN");
        $("#recruitmentInformation").html('<option value="">请选择应聘来源（必填）</option>');
        $.each(recruitmentInformation,function (index,item) {
            $("#recruitmentInformation").append('<option value="'+item.pkDataDictionaryId+'">'+item.dataDictionaryName+'</option>')
        });

        //加载应聘信息来源下拉框
        const healthMaimGrade=getAjaxById(getRootPath()+"OaDataDictionaryAction/findKeyword/MAIM");
        $("#healthMaimGrade").html('<option value="">请选择伤残等级</option>');
        $.each(healthMaimGrade,function (index,item) {
            $("#healthMaimGrade").append('<option value="'+item.pkDataDictionaryId+'">'+item.dataDictionaryName+'</option>')
        });
        //监听指定开关
        form.on('switch(switchTest)', function(data){
            /*layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });*/
            if(this.checked){
                $("#isHealthMaimLevel").show();
                $("#isHealthMaims").css("width","655px");
            }else{
                $("#isHealthMaimLevel").hide();
                $("#isHealthMaims").css("width","520px");
                $("#healthMaimGrade").val("");
            }
        });
        let res;
        if(pkEntryId){
            res =getAjaxById(getRootPath()+"oaEntryFlowAction/findById/"+pkEntryId);
        }else{
            res =getAjaxById(getRootPath()+"oaEntryFlowAction/addEntryFlow");
        }
        $("#pkEntryId").val(res.pkEntryId);
        $("#isRevision").val(res.isRevision);
        if(res){
            $("#entryArea").val(res.entryArea); // 姓名
            if(res.entryBirthday){
                $("#entryBirthday").val(dateFormat("yyyy-MM-dd",new Date(res.entryBirthday))); // 生日
            }
            $("#entryIdentity").val(res.entryIdentity); // 身份证
            $("#entryNation").val(res.entryNation); // 民族
            $("#entryNativeProvince").val(res.entryNativeProvince); // 籍贯
            $("#entryPostcodeResidence").val(res.entryPostcodeResidence); // 通讯邮编
            $("#entryPostcode").val(res.entryPostcode); // 现住邮编
            $("#entryPhone").val(res.entryPhone); // 电话
            $("#entryEducation").val(res.entryEducation); // 最高学历
            $("#entryMajor").val(res.entryMajor); // 专业
            $("#entryForeignLevel").val(res.entryForeignLevel); // 外语及等级
            $("#entryProfessionalQualification").val(res.entryProfessionalQualification); // 职业资格
            $("#entryMajorQualification").val(res.entryMajorQualification); // 专业职称
            $("#entryBankAccount").val(res.entryBankAccount); // 银行账户
            $("#entryBankName").val(res.entryBankName); // 开户行
            $("input[name=entrySex][value='0']").attr("checked", res.entrySex == 0 ? true : false); // 性别 女
            $("input[name=entrySex][value='1']").attr("checked", res.entrySex == 1 ? true : false); // 性别 男
            if(res.entrySex == null){
                $("input[name=entrySex][value='1']").attr("checked",true);
            }
            $("#entryNativeCity").val(res.entryNativeCity); // 户口所在地
            $("input[name=isMarriage][value='0']").attr("checked", res.isMarriage == 0 ? true : false); // 婚姻状况 已婚
            $("input[name=isMarriage][value='1']").attr("checked", res.isMarriage == 1 ? true : false); // 婚姻状况 未婚
            $("input[name=isMarriage][value='2']").attr("checked", res.isMarriage == 2 ? true : false); // 婚姻状况 离异
            $("input[name=isMarriage][value='3']").attr("checked", res.isMarriage == 3 ? true : false); // 婚姻状况 再婚
            if(res.isMarriage == null ){
                $("input[name=isMarriage][value='1']").attr("checked",true);
            }
            $("#entryCurrentResidence").val(res.entryCurrentResidence); // 现住地址
            $("#entryCommunicationResidence").val(res.entryCommunicationResidence); // 通信地址
            $("#healthHeight").val(res.healthHeight); // 身高
            $("#healthWeight").val(res.healthWeight); // 体重
            if(res.dimissionTime){
                $("#dimissionTime").val(dateFormat("yyyy-MM-dd",new Date())); // 参加工作时间
            }
            $("#accumulativeDate").val(res.accumulativeDate); // 累计工作时间
            $("#recruitmentInformation").val(res.recruitmentInformation); // 应聘信息来源
            $("#departmentId").val(res.departmentId); // 入职部门
            if(res.departmentId){
                const postId=getAjaxById(getRootPath()+"OaOrganizationAction/organizationFind/"+res.departmentId);
                $("#postId").html('<option value="">请选择岗位</option>');
                $.each(postId.data,function (index,item) {
                    $("#postId").append('<option value="'+item.pkPostId+'">'+item.postName+'</option>')
                });
            }
            $("#postId").val(res.postId); // 入职岗位
            if(res.affirmTime){
                $("#affirmTime").val(dateFormat("yyyy-MM-dd",new Date(res.affirmTime))); // 入职时间
            }
            $("input[name=isHealthEyesight][value='0']").attr("checked", res.isHealthEyesight == 0 ? true : false); // 视力 辅助
            $("input[name=isHealthEyesight][value='1']").attr("checked", res.isHealthEyesight == 1 ? true : false); // 视力 良好
            if(res.isHealthEyesight == null){
                $("input[name=isHealthEyesight][value='1']").attr("checked",true);
            }
            $("input[name=isHealthEar][value='0']").attr("checked", res.isHealthEar == 0 ? true : false); // 听力 辅助
            $("input[name=isHealthEar][value='1']").attr("checked", res.isHealthEar == 1 ? true : false); // 听力 良好
            if(res.isHealthEar == null){
                $("input[name=isHealthEar][value='1']").attr("checked",true);
            }
            $("#employCondition").val(res.employCondition); // 录用条件
            $("#isHealthInjury").attr("checked", res.isHealthInjury == 0 ? true : false); // 工伤
            $("#isHealthHeavyManual").attr("checked", res.isHealthHeavyManual == 0 ? true : false); // 高危工作
            $("#isHealthContagion").attr("checked", res.isHealthContagion == 0 ? true : false); // 传染疾病
            $("#isAnnualVacation").attr("checked", res.isAnnualVacation == 0 ? true : false); // 是否休完年假
            $("#isPenal").attr("checked", res.isPenal == 0 ? true : false); // 刑事记录
            $("#formeWork").attr("checked", res.formeWork == 0 ? true : false); // 本公司工作过
            $("#isHealthMaim").attr("checked", res.isHealthMaim == 0 ? true : false); // 伤残
            if(res.isHealthMaim == 0){
                $("#isHealthMaimLevel").show();
                $("#isHealthMaims").css("width","655px");
            }
            $("#healthMaimGrade").val(res.healthMaimGrade); // 伤残等级
            $("#healthTreat").val(res.healthTreat); // 医学治疗
            form.render();
        }

        oaEntryEducationTable = table.render({
            elem: '#oaEntryEducation'
            , url: getRootPath() + 'oaEntryEducation/selectAll?entryId='+$("#pkEntryId").val()
            , headers: {token: token}
            , title: '教育经历'
            , parseData: function (res) {
                if (res.code === 500) {
                    return false
                }
                return {
                    "code": res.data.code,
                    "msg": res.data.msg,
                    "count": res.data.count,
                    "data": res.data.data
                };
            }
            , cols: [[
               {type: 'numbers', title: '序列', fixed: 'left', width: 120}
                , {field: 'startTime', title: '开始时间',  templet: function (row) {
                        if (row.startTime) {
                            return dateFormat("yyyy-MM-dd", new Date(row.startTime));
                        } else {
                            return "";
                        }
                    }, width: 120}
                , {field: 'endTime', title: '结束时间',  templet: function (row) {
                        if (row.endTime) {
                            return dateFormat("yyyy-MM-dd", new Date(row.endTime));
                        } else {
                            return "";
                        }
                    }, width: 120}
                , {field: 'educationSchool', title: '院校名称', width: 120}
                , {field: 'educationDegreeName', title: '学历', width: 120}
                , {field: 'educationMajor', title: '专业', width: 120}
                , {field: 'educationSeries', title: '证书', width: 120}
                , {fixed: 'right', title: '操作', toolbar: '#barDemoOaEntryEducation', width: 120}
            ]]
        });
        //监听行工具事件
        table.on('tool(oaEntryEducation)', function (obj) {
            var data = obj.data;
            if (obj.event === 'delOaEntryEducation') {
                layer.confirm('真的删除行么', function (index) {
                    var url=getRootPath()+'oaEntryEducation/delete/' + data.pkEducationId;
                    var dataOne=deleteAjaxById(url);
                    if (dataOne.code === 1) {
                        oaEntryEducationTable.reload();
                        layer.msg('删除成功', {icon: 1});
                    }else {
                        layer.msg("删除失败")
                    }
                });
            }
        });

        oaEntryWorkTable = table.render({
            elem: '#oaEntryWork'
            , url: getRootPath() + 'oaEntryWork/selectAll?entryId='+$("#pkEntryId").val()
            , headers: {token: token}
            , title: '工作经历'
            , parseData: function (res) {
                if (res.code === 500) {
                    return false
                }
                return {
                    "code": res.data.code,
                    "msg": res.data.msg,
                    "count": res.data.count,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: 'numbers', title: '序列', fixed: 'left'}
                , {field: 'startTime', title: '开始时间',  templet: function (row) {
                        if (row.startTime) {
                            return dateFormat("yyyy-MM-dd", new Date(row.startTime));
                        } else {
                            return "";
                        }
                    }}
                , {field: 'endTime', title: '结束时间',  templet: function (row) {
                        if (row.endTime) {
                            return dateFormat("yyyy-MM-dd", new Date(row.endTime));
                        } else {
                            return "";
                        }
                    }}
                , {field: 'workUnit', title: '工作单位'}
                , {field: 'workPost', title: '职位'}
                , {field: 'voucher', title: '证明人姓名'}
                , {field: 'phone', title: '证明人电话'}
                , {field: 'reasonsForLeaving', title: '离职原因'}
                , {fixed: 'right', title: '操作', toolbar: '#barDemoOaEntryWork', width: 120}
            ]]
        });
        //监听行工具事件
        table.on('tool(oaEntryWork)', function (obj) {
            var data = obj.data;
            if (obj.event === 'delEntryWork') {
                layer.confirm('真的删除行么', function (index) {
                    var url=getRootPath()+'oaEntryWork/delete/' + data.pkWorkId;
                    var dataOne=deleteAjaxById(url);
                    if (dataOne.code === 1) {
                        oaEntryWorkTable.reload();
                        layer.msg('删除成功', {icon: 1});
                    }else {
                        layer.msg("删除失败")
                    }
                });
            }
        });
        oaEntryTrainTable = table.render({
            elem: '#oaEntryTrain'
            , url: getRootPath() + 'oaEntryTrain/selectAll?entryId='+$("#pkEntryId").val()
            , headers: {token: token}
            , title: '培训经历'
            , parseData: function (res) {
                if (res.code === 500) {
                    return false
                }
                return {
                    "code": res.data.code,
                    "msg": res.data.msg,
                    "count": res.data.count,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: 'numbers', title: '序列', fixed: 'left'}
                , {field: 'startTime', title: '开始时间',  templet: function (row) {
                        if (row.startTime) {
                            return dateFormat("yyyy-MM-dd", new Date(row.startTime));
                        } else {
                            return "";
                        }
                    }}
                , {field: 'endTime', title: '结束时间',  templet: function (row) {
                        if (row.endTime) {
                            return dateFormat("yyyy-MM-dd", new Date(row.endTime));
                        } else {
                            return "";
                        }
                    }}
                , {field: 'trainContent', title: '培训内容'}
                , {field: 'trainInstitutional', title: '培训组织机构'}
                , {field: 'trainResult', title: '培训结果'}
                , {fixed: 'right', title: '操作', toolbar: '#barDemoOaEntryTrain', width: 220}
            ]]
        });
        //监听行工具事件
        table.on('tool(oaEntryTrain)', function (obj) {
            var data = obj.data;
            if (obj.event === 'delEntryTrain') {
                layer.confirm('真的删除行么', function (index) {
                    var url=getRootPath()+'oaEntryTrain/delete/' + data.pkTrainId;
                    var dataOne=deleteAjaxById(url);
                    if (dataOne.code === 1) {
                        oaEntryTrainTable.reload();
                        layer.msg('删除成功', {icon: 1});
                    }else {
                        layer.msg("删除失败")
                    }
                });
            }
        });
        oaEntryFamilyTable=table.render({
            elem: '#oaEntryFamily'
            , url: getRootPath() + 'oaEntryFamily/selectAll?entryId='+$("#pkEntryId").val()
            , headers: {token: token}
            , title: '家庭成员'
            , parseData: function (res) {
                if (res.code === 500) {
                    return false
                }
                return {
                    "code": res.data.code,
                    "msg": res.data.msg,
                    "count": res.data.count,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: 'numbers', title: '序列', fixed: 'left'}
                , {field: 'familyName', title: '姓名'}
                , {field: 'relation', title: '关系'}
                , {field: 'familyEmployer', title: '工作单位'}
                , {field: 'post', title: '所在岗位及职务'}
                , {fixed: 'right', title: '操作', toolbar: '#barDemoOaEntryFamily', width: 220}
            ]]
        });

        //监听行工具事件
        table.on('tool(oaEntryFamily)', function (obj) {
            var data = obj.data;
            console.log(data)
            if (obj.event === 'delEntryFamily') {
                layer.confirm('真的删除行么', function (index) {
                    var url=getRootPath()+'oaEntryFamily/delete/' + data.pkFamilyId;
                    var dataOne=deleteAjaxById(url);
                    if (dataOne.code === 1) {
                        oaEntryFamilyTable.reload();
                        layer.msg('删除成功', {icon: 1});
                    }else {
                        layer.msg("删除失败")
                    }
                });
            }
        });
        oaEmergencyContactTable=table.render({
            elem: '#oaEmergencyContact'
            , url: getRootPath() + 'oaEmergencyContact/selectAll?entryId='+$("#pkEntryId").val()
            , headers: {token: token}
            , title: '紧急联络人'
            , parseData: function (res) {
                if (res.code === 500) {
                    return false
                }
                return {
                    "code": res.data.code,
                    "msg": res.data.msg,
                    "count": res.data.count,
                    "data": res.data.data
                };
            }
            , cols: [[
                {type: 'numbers', title: '序列', fixed: 'left'}
                , {field: 'emergencyContactName', title: '姓名'}
                , {field: 'relation', title: '关系'}
                , {field: 'emergencyContactAddress', title: '联系地址'}
                , {field: 'emergencyContactPostcode', title: '联系邮编'}
                , {field: 'emergencyContactPhone', title: '电话'}
                , {fixed: 'right', title: '操作', toolbar: '#barDemoEmergencyContact', width: 220}
            ]]
        });
        //监听行工具事件
        table.on('tool(oaEmergencyContact)', function (obj) {
            var data = obj.data;
            if (obj.event === 'delEmergencyContact') {
                layer.confirm('真的删除行么', function (index) {
                    var url=getRootPath()+'oaEmergencyContact/delete/' + data.emergencyContactId;
                    var dataOne=deleteAjaxById(url);
                    if (dataOne.code === 1) {
                        oaEmergencyContactTable.reload();
                        layer.msg('删除成功', {icon: 1});
                    }else {
                        layer.msg("删除失败")
                    }
                });
            }
        });
        //监听起草提交
        form.on('submit(demo1)', function (data) {
            submit_is(data.field);
            console.info(data.field);
            const res=postAjax(getRootPath()+"oaEntryFlowAction/audit",data.field);
            if (res.code === 1) {
                layer.msg('新增成功3秒后关闭当前窗口', {icon: 1});
                setTimeout(function () {
                    formClose();
                },3000);
                setTimeout(function () {
                    parent.layui.table.reload('test');//刷新父页面
                    //window.parent.location.reload();//刷新父页面
                    const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                },3000);
                //window.location.reload();//刷新页面
            } else if (res.code === 500) {
                error('500');
            } else {
                layer.msg("新增失败");
            }
            return false;
        });

        $("#demo2").on('click',function () {
            //表单取值
            var data = form.val('example');
            submit_is(data);
            console.info(data);
            const res=postAjax(getRootPath()+"oaEntryFlowAction/addTemporary",data);
            if (res.code === 1) {
                layer.msg('暂存成功3秒后关闭当前窗口', {icon: 1});
                setTimeout(function () {
                    formClose();
                },3000);
                setTimeout(function () {
                    parent.layui.table.reload('test');//刷新父页面
                    //window.parent.location.reload();//刷新父页面
                    const index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                },3000);
                //window.location.reload();//刷新页面
            } else if (res.code === 500) {
                error('500');
            } else {
                layer.msg("新增失败");
            }
        });

        const ress=getAjaxById(getRootPath()+"OaFlowAction/selectFlowSchedule/"+$("#pkEntryId").val());
        $("#schedule").html("");
        $.each(ress,function (index,item) {
            if (item.createdBy) {
                $("#schedule").append('<li class="layui-timeline-item">\n' +
                    '        <i class="layui-icon layui-timeline-axis"></i>\n' +
                    '        <div class="layui-timeline-content layui-text">\n' +
                    '            <h3 class="layui-timeline-title">' + dateFormat('yyyy-MM-dd hh:mm:ss', new Date(item.createdTime)) + '&nbsp;&nbsp;&nbsp;' + item.flowName + '</h3>\n' +
                    '            <p>' + item.formReason + '</p>\n' +
                    '            <p>操作人：' + item.createdBy + '</p>\n' +
                    '        </div>\n' +
                    '    </li>')

            } else {
                $("#schedule").append('<li class="layui-timeline-item">\n' +
                    '        <i class="layui-icon layui-timeline-axis"></i>\n' +
                    '        <div class="layui-timeline-content layui-text">\n' +
                    '            <h3 class="layui-timeline-title">' + dateFormat('yyyy-MM-dd hh:mm:ss', new Date(item.createdTime)) + '&nbsp;&nbsp;&nbsp;' + item.flowName + '</h3>\n' +
                    '            <p>' + item.formReason + '</p>\n' +
                    '        </div>\n' +
                    '    </li>')
            }
        });


        if(isButton("ENTRY_CHECK") && $("#isRevision").val()==="L"){
            $("#entryCheck").show();
            $("#trialDate").attr("lay-verify","required");
            $("#trialMoney").attr("lay-verify","required");
            $("#officialMoney").attr("lay-verify","required");
        }
        $("#bodys").show();
        form.render();
    });



    /**
     * 判断框赋值
     * @param data
     */
    function submit_is(data) {
        //是否曾被认定为工伤或职业病或持有残疾人证明
        if($("#isHealthInjury").prop("checked")){
            data.isHealthInjury="0";
        }else{
            data.isHealthInjury="1";
        }
        //是否从事过井下、高空、高温、特别繁重体力劳动已经有毒有害工种
        if($("#isHealthHeavyManual").prop("checked")){
            data.isHealthHeavyManual="0";
        }else{
            data.isHealthHeavyManual="1";
        }
        //是否有传染性疾病以及何疾病
        if($("#isHealthContagion").prop("checked")){
            data.isHealthContagion="0";
        }else{
            data.isHealthContagion="1";
        }
        //是否已经休了本年度年休假
        if($("#isAnnualVacation").prop("checked")){
            data.isAnnualVacation="0";
        }else{
            data.isAnnualVacation="1";
        }
        //是否曾经或正在追究与承担过刑事责任
        if($("#isPenal").prop("checked")){
            data.isPenal="0";
        }else{
            data.isPenal="1";
        }
        //是否在本公司工作过
        if($("#formeWork").prop("checked")){
            data.formeWork="0";
        }else{
            data.formeWork="1";
        }
        //是否被劳动能力鉴定委员会鉴定为具有伤残等级以及几何级伤残
        if($("#isHealthMaim").prop("checked")){
            data.isHealthMaim="0";
        }else{
            data.isHealthMaim="1";
        }
    }
</script>
</body>
</html>